package cn.yangliu.nacos.comm.config.feign;

import feign.codec.Decoder;
import feign.codec.Encoder;
import feign.codec.ErrorDecoder;
import org.springframework.boot.autoconfigure.AutoConfigureBefore;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.cloud.openfeign.FeignAutoConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * The type of nacos.
 *
 * @author 问道于盲
 * @date 2020 -01-05
 */
@Configuration
@ConditionalOnClass(FeignAutoConfiguration.class)
@AutoConfigureBefore(FeignAutoConfiguration.class)
public class FeignConfig {

    /**
     * Feign jackson encoder encoder.
     *
     * @return the encoder
     */
    @Bean
    public Encoder feignJacksonEncoder(){
        return new FeignJacksonEncoder();
    }

    /**
     * Feign jackson decoder decoder.
     *
     * @return the decoder
     */
    @Bean
    public Decoder feignJacksonDecoder(){
        return new FeignJacksonDecoder();
    }

    /**
     * Feign error decoder error decoder.
     *
     * @return the error decoder
     */
    @Bean
    public ErrorDecoder feignErrorDecoder(){
        return new FeignErrorDecoder();
    }
}
